/*
* License:  This  program  is  free  software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the  Free Software Foundation; either version 3 of the License, or (at your
* option)  any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*/

package pcgen.CharacterViewer.resources;

import java.util.ArrayList;

import android.os.Parcel;
import android.os.Parcelable;

import pcgen.android.Logger;

public class GameResourceHistoryList extends ArrayList<GameResourceHistory> implements Parcelable
{
	private static final long serialVersionUID = 663585476779879096L;

	public GameResourceHistoryList()
	{
	}

	public GameResourceHistoryList(Parcel in)
	{
		readFromParcel(in);
	}

	@SuppressWarnings("rawtypes")
	public static final Parcelable.Creator CREATOR = new Parcelable.Creator() 
	{
		public GameResourceHistoryList createFromParcel(Parcel in) 
		{
			return new GameResourceHistoryList(in);
		}
		
		public GameResourceHistoryList[] newArray(int size) 
		{
		    return new GameResourceHistoryList[size];
		}
	};

	public int describeContents() 
	{
		return 0;
	}

	public void readFromParcel(Parcel in) 
	{
		try
		{
			this.clear();
	
			int size = in.readInt();
			
			for (int i = 0; i < size; i++) 
			{
				GameResourceHistory item = (GameResourceHistory)in.readParcelable(GameResourceHistory.class.getClassLoader());
			   	add(item);
			}
		}
		catch (Throwable tr)
		{
			Logger.e(TAG, "readFromParcel", tr);
		}
	}

	public void writeToParcel(Parcel dest, int flags) 
	{
		try
		{
			int size = this.size();
		   	dest.writeInt(size);
	
		   	for (GameResourceHistory item : this)
			   	dest.writeParcelable(item, flags);
		}
		catch (Throwable tr)
		{
			Logger.e(TAG, "writeToParcel", tr);
		}
	}
    
    private static final String TAG = GameResourceHistoryList.class.getSimpleName();
}
